﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Windows;
using System.Windows.Input;
// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using BrainTechLLC;
using BrainTechLLC.FilterExtensions;
using ImageAppDataModels;
using ImageAppViewModels;


namespace WpfImageDuplicates
{
    public partial class Extra1Command : RoutedCommand, ICommand
    {
        public void Execute(FileImageCollectionViewModelCollection viewModels)
        {
            foreach (var viewModel in viewModels)
            {
                for (int n = 0; n < viewModel.Count; n++)
                {
                    var vm = viewModel[n];
                    var fn = vm.FileName;
                    if (fn.Contains("- Copy"))
                    {
                        fn = fn.Replace("- Copy", "");
                        fn = fn.Replace("  ", " ");
                        fn = fn.Replace(" .", ".");
                        vm.Rename(fn);
                    }
                }
            }
        }
    }
}
